package com.emergency.direct.controller;

import com.emergency.direct.service.TaskService;
import com.emergency.base.domain.ScenarTask;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lijie on 2019/10/21.
 */
@RestController
@RequestMapping("/task")
@Api(value="任务类",description = "任务编辑类，包括任务基本信息，任务目标")
public class TaskController {

    @Autowired
    private TaskService taskService;

    @ApiOperation(value = "任务增加接口" ,  notes="任务增加")
    @RequestMapping(value = "info/add",method = RequestMethod.POST)
    public Result add(@RequestBody ScenarTask task){
        taskService.add();
        return new Result(true, StatusCode.OK,  "操作成功", "");
    }

    @ApiOperation(value = "任务修改接口" ,  notes="任务修改")
    @RequestMapping(value = "info/update",method = RequestMethod.POST)
    public Result update(@RequestBody ScenarTask task){
        taskService.update();
        return new Result(true, StatusCode.OK,  "操作成功", "");
    }

    @ApiOperation(value = "任务删除接口" ,  notes="任务删除")
    @RequestMapping(value = "info/delete",method = RequestMethod.POST)
    public Result delete(long id){
        taskService.delete();
        return new Result(true, StatusCode.OK,  "操作成功", "");
    }

    @ApiOperation(value = "任务信息获取接口" ,  notes="任务信息获取")
    @RequestMapping(value = "info/get",method = RequestMethod.POST)
    public Result get(){
        taskService.get();
        return new Result(true, StatusCode.OK,  "操作成功", "");
    }

}
